/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mrp.productionPlanning.managedbean;

import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.event.ActionEvent;
import mrp.productionPlanning.entity.MonthlyDetailEntity;
import mrp.productionPlanning.session.DailyDetailSessionBean;
import mrp.productionPlanning.session.MonthlyDetailSessionBean;
import mrp.productionPlanning.session.WeeklyDetailSessionBean;

/**
 *
 * @author Wei Haoyang
 */
@ManagedBean
@RequestScoped
public class GenerateCalendarManagedBean {
    
    
    private int year;
    @EJB
    MonthlyDetailSessionBean mdsb = new MonthlyDetailSessionBean();
    @EJB
    WeeklyDetailSessionBean wdsb = new WeeklyDetailSessionBean();
    @EJB
    DailyDetailSessionBean ddsb = new DailyDetailSessionBean();
    
    /** Creates a new instance of GenerateCalendarManagedBean */
    public GenerateCalendarManagedBean() {
    }
    
    public void generate(ActionEvent event) throws ParseException{
        ddsb.generateAYear(year);
        System.out.println("-------------------------------------Check Point3---------------------------------------");
        mdsb.generateAYear(year);
        System.out.println("-------------------------------------Check Point4---------------------------------------");
        wdsb.generateAYear(year);
        List<MonthlyDetailEntity> mds = new ArrayList<MonthlyDetailEntity>();
        for(MonthlyDetailEntity md:mds){
            mdsb.setDays(md);
        }
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }
}
